package org.arain.baseii.system.oplog;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.arain.baseii.grid.AMGrid;
import org.arain.baseii.grid.ColumnsPojo;
import org.arain.baseii.grid.QueryParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 
* <p>Title:SysOplogController </p>
* @author Arain
* @date2017年9月5日
 */
@Controller
@RequestMapping("/system/handlelog")
public class SysOplogController {
	@Autowired
	private SysOplogService sysOplogService;
	
	@RequestMapping("list_01")
	public String list_01(Model model) {
		List<ColumnsPojo> columns = new ArrayList<>();
		AMGrid grid = new AMGrid("logId");
		grid.setUrl("/system/handlelog/load_grid.do");
		grid.setToolbar("HandlelogToolbar");
		ColumnsPojo pojo;
		pojo = new ColumnsPojo("logMethed", "操作方法");
		columns.add(pojo);
		pojo = new ColumnsPojo("logUser", "操作人员");
		columns.add(pojo);
		pojo = new ColumnsPojo("logTime", "操作时间");
		columns.add(pojo);
		pojo = new ColumnsPojo("logUrl", "操作路径");
		columns.add(pojo);
		pojo = new ColumnsPojo("logIp", "操作IP");
		columns.add(pojo);
		pojo = new ColumnsPojo("logSuccess", "操作状态");
		columns.add(pojo);
		grid.setColumns(columns.toString());
		
		model.addAttribute("dataGrid", grid.toString());
		return "/system/handlelog/list_01";
	}
	
	@RequestMapping(value="load_grid.do",produces="text/json;charset=UTF-8")
	@ResponseBody
	public String load_grid(QueryParam param) {
		return sysOplogService.load_grid(param);
	}
	
	@RequestMapping("view_01")
	public String view_01(SysOplogDto dto,HttpServletRequest request,Model model) {
		dto = sysOplogService.load_01(dto);
		model.addAttribute("SysOplogDto", dto);
		return "system/handlelog/add_01";
	}
}
